import os

import pytest,logging,yagmail,time

def log():
    times=time.strftime('%H%m%d_%H%M%S')
    logging.basicConfig(level=logging.DEBUG,
                        format='%(levelname)s %(message)s %(filename)s %(asctime)s %(lineno)s',
                        filename=times+'api_test.log',
                        filemode='w+')
    return times+'api_test.log'
def send(file):
    mail=yagmail.SMTP(user='3034738910@qq.com',password='aytttpqxjbbrddjh',host='smtp.qq.com')
    mail.send(to='3034738910@qq.com',subject='测试报告',contents='今日报告请查收',attachments=file)
if __name__ == '__main__':
    log()
    pytest.main(['-s',r'C:\Users\30347\PycharmProjects\yuekao_1110\case\case.py','--clean-alluredir','--alluredie=./request','--html=./html'])
    os.system('allure generate .html ./request ./html --clean')
    send(['api_test.log',r'C:\Users\30347\PycharmProjects\yuekao_1110\yuekao\Api\allure-report\index.html'])
